<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>确认入驻</title>
    <link href="../static/lib/bootstrap/css/bootstrap.css" th:href="@{/lib/bootstrap/css/bootstrap.min.css}"
          rel="stylesheet"/>
</head>
<body>
<div id="logo-bar" >
    <img src="../static/img/logo.png" th:src="@{/img/logo.png}" class="img-responsive">
</div>
<div class="jumbotron">
    <div class="row">
        <div class="col-xs-6 col-xs-offset-3">
            <h1><span th:text="${teamName}">TPW</span>团队</h1>
            <p>恭喜您获得演武创客空间的入驻资格，请点一下按钮进行确认。</p>
            <p>确认入驻之后会发一封邮件到团队负责人的邮箱，请仔细阅读里面的事项并尽快到科研楼办理入驻。</p>
            <p>
                <button class="btn btn-primary btn-block" id="confirm-btn">确认入驻</button>
            </p>
        </div>
    </div>
</div>
<script type="text/javascript" th:inline="javascript">
    /*<![CDATA[*/
    var requestRootUrl = /*[[@{/}]]*/"http://rapapi.org/mockjs/22290/";
    var forwardUrl = /*[[@{/}]]*/ "index.html";

    var transferData = {
        teamId: /*[[${teamId}]]*/"1234567"
    }
    /*]]>*/
</script>
<script src="../static/lib/jquery/jquery.js" th:src="@{/lib/jquery/jquery.min.js}"></script>
<script>
    $("#confirm-btn").click(function (e) {

        var obj = this;
        // 禁用按钮
        $(this).removeClass("btn-primary").addClass("btn-success").addClass("disabled").html("提交中");

        // TODO: url路径要改
        $.ajax({
            url:requestRootUrl + "api/team-in/confirm-enter",
            data:JSON.stringify(transferData),
            contentType:"application/json",
            type:"post",
            success:function (data) {
                alert("您已经成功入驻!");

                window.location.href = forwardUrl;
            },
            error: function () {
                alert("似乎出现了点问题!!!∑(ﾟДﾟノ)ノ!");

                window.location.reload();
            }
        })
    });
</script>
</body>
</html>